﻿<script language="javascript" type="text/javascript" src="<?php echo base_url().'assets/tiny_mce/tiny_mce.js'; ?>"></script>
<script language="javascript" type="text/javascript">
  tinyMCE.init({
    mode : "textareas",
    theme : "advanced",
    editor_deselector : "noEditor",
    entity_encoding : "raw",
    elements : "canswer",
	width : 700,
	height : 400,
    
    theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,|,fontsizeselect,forecolor,backcolor,link,unlink,anchor,image,separator,code",
    theme_advanced_buttons2 : "",
    theme_advanced_buttons3 : "",
    theme_advanced_buttons4 : "",
    theme_advanced_toolbar_location : "top",
    theme_advanced_toolbar_align : "left",
    convert_urls : false,
    file_browser_callback : 'fileManager',
    accessibility_warnings : false
  });
</script>
<div id="pagecontent">
<div id="add" style="cursor:pointer; float:right; font-weight:bold; color:#FF0066;"><span id="actionname" style="text-decoration:overline">CREATE NEWSLETTER</span> <img  src="<?php echo base_url(); ?>assets/img/icon-32-new.png" title="<?php echo $this->lang->line('m_addmenu'); ?>" align="absmiddle"/> </div>
<?php 
	if($this->session->flashdata('message')!='')
	{ 
		
?>
<div id="sponsorAdDiv" style="visibility:hidden">
<table width="305px" height="50px" bgcolor="#FF0000"><tr><td>
<table width="300px" height="45px" bgcolor="#FFFFCC"><tr><td align="center" valign="middle">
<?php echo $this->session->flashdata('message'); ?>
</p>
</td></tr></table></td></tr></table>
</div>
<?php
	}
?>
<div id="addbigcontent">
  <div id='addmenu'> 
<form action="<?php echo base_url().index_page(); ?>/adminpage/cpanel/sendmail_newsletter/" method="post" name="adminForm" id="adminForm" autocomplete="off">
    <fieldset style="border:none">
    <div id="addnew"><div align="center" class="error_validate" id="error_message"></div>
      <div>
        <label for="canswer">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Mail content</label>
        <textarea id="canswer"  name="answer" cols="80" rows="20"></textarea>
      </div>

    </div>
  
    <input type="hidden" name="component" value="com_newsletter" />
    <input type="hidden" id="option" name="option" value="send_newsletter" />
    <input type="hidden" name="myurl" value="<?php echo base_url().index_page().$this->uri->uri_string(); ?>" />
    <input type="hidden" id="id" name="id" value="" />
    <input type="hidden" name="task" value="" />
    <div class="toolbar"  align="center">
      <table width="160px" border="0" align="center" cellpadding="5">
        <tr>
          <td align="center"><div id="mybutton" onclick="javascript: submitbutton('save')"><a href="#"><span class="icon-32-save" title="<?php echo $this->lang->line('btsend'); ?>"></span><?php echo $this->lang->line('btsend'); ?></a></div></td>
          <td align="center"><div id="mybutton2"><a onclick="document.adminForm.reset()" href="#"><span class="icon-32-cancel" title="<?php echo $this->lang->line('reset'); ?>"> </span><?php echo $this->lang->line('reset'); ?></a></div></td>
        </tr>
      </table>
    </div>
  </fieldset>
</form><div style="padding-left:220px"><br /><hr width="400px" /><br /></div>
  </div> 
</div>
<div id="listmenu" align="center" style="width:100%; padding-left:0px;"> 
<table width="80%" id="tablesorter-demo" class="tablesorter" border="0" cellpadding="0" cellspacing="1">
  <thead>
  <tr>
    <th align="center" width="40%">Email</th>
    <th align="center" width="40%">Registered date</th>
    <th align="center" width="20%" class="{sorter: false}"><?php echo $this->lang->line('table_header_action'); ?></th>
  </tr>
  </thead>
  <tbody>
   <?php 
   if (isset($newsletter))
   {
				for($i=0;$i<count($newsletter);$i++)
				{
					$td_bg=($i%2==0)?"":" background-color:#f0f0f6";
					echo "<tr><td style='padding-left:10px;".$td_bg.";'>".$newsletter[$i]['email']."</td><td  align='center' style='padding-left:10px;".$td_bg.";'>".date("d-m-Y",$newsletter[$i]['register_date'])."</td><td  align='center' style='padding-left:10px;".$td_bg.";'><a  style='color:#FF3366; text-decoration:underline;cursor:pointer'  onclick='checkdelete(".$newsletter[$i]['id'].")'>Delete</a></td></tr>";
				}
	}
	?> 
  </tbody>
</table>
  </div> 
  <?php
		if ($this->pagination->create_links()!='')
		{
			 echo '<p align="right"><strong>Page </strong><span style="color:#FF0000">'.$this->pagination->create_links(); 
		}
?>  
</div>
<script>
  $(document).ready(function(){
    $("#addmenu").hide();
	//$("img#vietnam").addClass('activelanguage');
    $("#add").click(function () {
	  //$("#addmenu").show('slow');
	  $('#addmenu').toggle(400); // First click should toggle to 'show'
      return false;

    });
  });

function checkdelete(id)
{	
	var value = confirm("<?php echo $this->lang->line('meg_confirm') ?>");
	if (value==false)
	{
		return;
	}
	else
	{
		location.href='<?php echo base_url().index_page()."/adminpage/cpanel/delete_newsletter/"; ?>'+id;
	}
}

function checkvalidate() 
{
	canswer=tinyMCE.activeEditor.getContent();   // get the content of Textarea
	
	if (canswer=="")
	{
		document.getElementById("error_message").innerHTML="The content is required.";
		return 0;
	}
	else
	{
		return 1;
	}
}
</script>